package com.lkx.farmershop.controller;

import com.lkx.farmershop.common.api.ApiResult;
import com.lkx.farmershop.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/tag")
public class TagController {

    @Autowired
    private TagService tagService;

    /**
     * 获取热门标签（被使用次数最多的前15个标签）
     * @return
     */
    @GetMapping("/getHotTags")
    public ApiResult<List<String>> getHotTags() {
        return tagService.getHotTags();
    }

    @GetMapping("/getUserTag")
    public ApiResult<List<String>> getUserTag(@RequestParam("userId") Long userId) {
        return tagService.getUserTag(userId);
    }

    @PutMapping("/updateTags")
    public ApiResult<String> updateTags(@RequestParam("tags") List<String> tags, @RequestParam("userId") Long userId) {
        return tagService.updateTags(userId, tags);
    }

}
